
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from mysite.settings import jumpserver_url
from cmdb.models import *

def index(request):
    return render(request, 'index.html', {})
    # return HttpResponseRedirect('cmdb/user/login')

def login(request):
    if request.session.has_key('username'):
        return HttpResponseRedirect('/cmdb/equipment')
    else:
        context = {
            'jumpserver_url' : jumpserver_url
        }
        if request.GET.has_key('next'):
            nextUrl =  request.get_full_path().split('next=')
            url = request.get_host() + nextUrl[1]
            context['current_url'] = url
        return render(request, 'home.html', context)

